package cn.jtfadmin.cms.domain.dto;

import lombok.Data;
import org.springframework.util.StringUtils;

import java.io.Serializable;

/**
 * cms 头部信息
 */
@Data
public class CmsPageHeadDTO implements Serializable {

    /**
     * 标题 head <title>title</title>
     */
    protected String title;

    /**
     * 关键字 head <meta name="keywords" content="title"/>
     */
    protected String keywords;

    /**
     * 页面描述 head <meta name="description" content="title"/>
     */
    protected String description;

    /**
     * js 增强
     */
    protected String scriptAdd;

    /**
     * css 增强
     */
    protected String styleAdd;



    public CmsPageHeadDTO() {
    }

    public CmsPageHeadDTO(String title, String keywords, String description, String scriptAdd, String styleAdd) {
        this.title = title;
        this.keywords = keywords;
        this.description = description;
        this.scriptAdd = scriptAdd;
        this.styleAdd = styleAdd;
    }

    public void meger(CmsPageHeadDTO dto){
        if(StringUtils.hasText(dto.description)){
            this.description = dto.description;
        }
        if(StringUtils.hasText(dto.keywords)){
            this.keywords = dto.keywords;
        }
        if(StringUtils.hasText(dto.title)){
            this.title = dto.title;
        }
        if(StringUtils.hasText(dto.scriptAdd)){
            if(StringUtils.hasText(scriptAdd)){
                this.scriptAdd = this.scriptAdd + "\r\n" +dto.scriptAdd;
            }else {
                this.scriptAdd = dto.scriptAdd;
            }

        }
        if(StringUtils.hasText(dto.styleAdd)){
            if(StringUtils.hasText(styleAdd)){
                this.styleAdd = this.styleAdd + "\r\n" +dto.styleAdd;
            }else {
                this.styleAdd = dto.styleAdd;
            }
        }
    }
}
